package com.wgo.precise.server.trigger;

import java.util.Date;

import remato.domain.server.ejb.PropertySetEjb;

import com.wgo.bpot.domain.common.CrudOperation;
import com.wgo.bpot.server.persist.PersistService;
import com.wgo.bpot.server.persist.trigger.Trigger;

public class BeforeSaveOrUpdatePropertySetTrigger implements Trigger<PropertySetEjb> {
	
	public void trigger(PropertySetEjb triggerTarget) {
		Date now = new Date();
		triggerTarget.setUpdatedDate(now);
	}

	public boolean isApplicable(Object persistent) {
		return (null != persistent) && (PropertySetEjb.class.isInstance(persistent));
	}

	public boolean isApplicable(CrudOperation operation) {
		return CrudOperation.UPDATE.equals(operation) || CrudOperation.CREATE.equals(operation);
	}

	public boolean isBefore() {
		return true;
	}

	public void setPersistService(PersistService persistService) {
	}

}
